<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function fun(){
            var t1 = /^\d{3,6}$/.test(document.getElementById("username").value);
            var t2 = /^\d{11,11}$/.test(document.getElementById("phone").value);
            if (t1 && t2){
                alert("格式正确")
            }else{
                alert("格式错误")
            }

        }
    </script>
</head>
<body>
    <input type="text" id="username" placeholder="用户名3-6位数字">
    <input type="text" id="phone" placeholder="电话11位数字">
    <input type="button" value="ok" onclick="fun()">
</body>
</html>